<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>

<body>
  <h1>登录</h1>
  用户名：<input type="text" id="username">
  <br>
  密码：<input type="text" id="password">
  <br>
  <button id="login">登录</button>
  <script src="./tool/utils.js"></script>
  <script>
    var login = document.getElementById("login");
    // 给登录按钮绑定点击事件
    login.addEventListener("click", function () {
      var usernameval = document.getElementById("username").value;
      var passwordVal = document.getElementById("password").value;
      var cookieUser = getCookie("user");//cookie存储的用户名
      var cookiePassword = getCookie("password"); //cookie 存储的密码
      if (usernameval == cookieUser) {
        if (passwordVal == cookiePassword) {
          alert("登录成功")
        } else {
          alert("密码错误")
        }
      } else {
        alert("用户名错误")
      }

    }, true)





  </script>
</body>

</html>